<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import systemDeviceLog from '@/api/system/systemDeviceLog'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()
const props = defineProps(["client", "curDevieInfo"]);


const numberOperation = (newValue, id, numberName) => {
  systemDeviceLog.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}

const switchStatus = (statusValue, id, statusName) => {
  systemDeviceLog.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  beforeRequest: params => {
        // 指定排序字段为浏览量字段
        params.device_num = props.curDevieInfo.device_num

           // 指定排序字段为浏览量字段
           params.orderBy = 'id'
        // 指定降序排序
        params.orderType = 'desc'

    },

  id: 'system_device_log',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: systemDeviceLog.getList,
  recycleApi: systemDeviceLog.getRecycleList,
  add: {
    show: false,
    api: systemDeviceLog.save,
    auth: ['system:deviceLog:save']
  },
  edit: {
    show: false,
    api: systemDeviceLog.update,
    auth: ['system:deviceLog:update']
  },
  delete: {
    show: true,
    api: systemDeviceLog.deletes,
    auth: ['system:deviceLog:delete'],
    realApi: systemDeviceLog.realDeletes,
    realAuth: ['system:deviceLog:realDeletes']
  },
  recovery: {
    show: true,
    api: systemDeviceLog.recoverys,
    auth: ['system:deviceLog:recovery']
  },
  import: {
    show: false,
    url: 'system/deviceLog/import',
    templateUrl: 'system/deviceLog/downloadTemplate',
    auth: ['system:deviceLog:import']
  },
  export: {
    show: true,
    url: 'system/deviceLog/export',
    auth: ['system:deviceLog:export']
  }
})

const columns = reactive([
  {
    title: "",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入"
    }
  },
  {
    title: "消息ID",
    dataIndex: "message_id",
    formType: "input",
    search: true
  },
  {
    title: "设备编码",
    dataIndex: "device_num",
    formType: "input",
    search: true
  },
  {
    title: "指令名称",
    dataIndex: "name",
    formType: "input"
  },
  {
    title: "指令",
    dataIndex: "order_name",
    formType: "input"
  },
  {
    title: "执行结果",
    dataIndex: "order_result",
    formType: "input"
  },
  {
    title: "所属点位",
    dataIndex: "point_id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "操作时间",
 
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: false,
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "所属区域",
    dataIndex: "dept_id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }

])
</script>
<script> export default { name: 'system:deviceLog' } </script>